#include <cstdio>
#include <algorithm>
#include <cmath>
#define min(a,b) ((a)<(b)?(a):(b))

using namespace std;

struct Node
{
    double x, y;
};

bool operator < ( const Node &a, const Node &b )
{
    return a.x < b.x;
}

double distances( Node a, Node b )
{
    return sqrt( ( a.x - b.x ) * ( a.x - b.x ) + ( a.y - b.y ) * ( a.y - b.y ) );
}

Node a[ 510 ];
int n;
double f[ 510 ][ 510 ];

void init( )
{
    int i;
    for ( i = 0; i < n; i++ )
        scanf("%lf%lf", &a[ i ].x, &a[ i ].y);
    a[ n ].x = a[ n ].y = 0;
    sort( a, a + n + 1 );
}

void work( )
{
    int i, j;
    double ans = 1e15;
    for ( i = 0; i <= n; i++ )
        for ( j = 0; j <= n; j++ )
            f[ i ][ j ] = 1e15;
    f[ 0 ][ 0 ] = 0;
    for ( i = 0; i < n; i++ )
        for ( j = 0; j <= i; j++ )
        {
            f[ i + 1 ][ j ] = min( f[ i + 1 ][ j ], f[ i ][ j ] + distances( a[ i + 1 ], a[ i ] ) );
            f[ i + 1 ][ i ] = min( f[ i + 1 ][ i ], f[ i ][ j ] + distances( a[ i + 1 ], a[ j ] ) );
        }
    for ( i = 0; i < n; i++ )
        ans = min( ans, f[ n ][ i ] + distances( a[ n ], a[ i ] ) );
    printf("%.2lf\n", ans);
}

int main( )
{
    while ( scanf("%d", &n) && n )
    {
        init( );
        work( );
    }
    return 0;
}
